package com.xinchen.aiowaste.ui.activity

import android.os.Bundle
import android.widget.ImageView
import androidx.activity.viewModels
import androidx.lifecycle.Observer
import com.maple.utils.const.ConstKey
import com.xinchen.aiowaste.R
import com.xinchen.aiowaste.base.BaseActivity
import com.xinchen.aiowaste.vm.StorageViewModel

class InStorageActivity : BaseActivity() {


    private var ivDangerousWaste: ImageView? = null
    private var ivIndustryWaste: ImageView? = null

    private val viewModel by viewModels<StorageViewModel>()

    override fun getLayoutId(): Int = R.layout.activity_in_storage

    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
        setTitle("入库管理")
        showClockTime()
        onBackClick()

        ivDangerousWaste = findViewById(R.id.iv_dangerous_waste)
        ivIndustryWaste = findViewById(R.id.iv_industry_waste)
        ivDangerousWaste?.setOnClickListener {
            val bundle: Bundle = Bundle()
            bundle.putString(ConstKey.BundleKey.EXTRA_TYPE,WasteListActivity.TYPE_IN_DANGEROUS)
            onStartActivity(WasteListActivity::class.java,bundle = bundle)
        }
        ivIndustryWaste?.setOnClickListener {
            val bundle: Bundle = Bundle()
            bundle.putString(ConstKey.BundleKey.EXTRA_TYPE,WasteListActivity.TYPE_IN_INDUSTRY)
            onStartActivity(WasteListActivity::class.java,bundle = bundle)
        }
    }
    override fun initData(savedInstanceState: Bundle?) {
        viewModel.defUI.showDialog.observe(this, Observer {
            showLoading()
        })

        viewModel.defUI.dismissDialog.observe(this, Observer {
            dismissLoading()
        })

        viewModel.defUI.toastEvent.observe(this, Observer {
            showToast(it)
        })
    }
}